package bi.dateSyn;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import java.util.UUID;

import bi.i99click.Get99clickData;

public class DateSynImp extends DataSource {
	public void doDateSyn(String sql, Object[] obj) {

		PreparedStatement pst;
		Get99clickData gcd = new Get99clickData();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
		String str = "20141231";

		try {
			Date dt = sdf.parse(str);
			Calendar rightNow = Calendar.getInstance();
			rightNow.setTime(dt);
			while (true) {
				pst = this.conn
						.prepareStatement("INSERT INTO bi_trafficDaily VALUES (?,?,?,?,?,?,?,?,?)");
				rightNow.add(Calendar.DAY_OF_YEAR, 1);// 日期加1天
				Date dt1 = rightNow.getTime();
				if (dt1.after(new Date()))
					break;
				Map<String, String> datas = gcd.trafficdaily(dt1);
				pst.setString(0, UUID.randomUUID().toString());
				
				ResultSet ret = pst.executeQuery();
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			this.close();
		}
	}

	public static void main(String[] args) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		String str = "20141231";
		try {
			Date dt = sdf.parse(str);
			Calendar rightNow = Calendar.getInstance();
			rightNow.setTime(dt);
			while (true) {
				rightNow.add(Calendar.DAY_OF_YEAR, 1);// 日期加1天
				Date dt1 = rightNow.getTime();
				if (dt1.after(new Date()))
					break;
				String reStr = format.format(dt1);
				System.out.println(reStr);
			}
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
